#include <iostream>
#include <string>

#include "AIGCJson-master/include/AIGCJson.hpp"

struct Job {
  std::string get_position() const { return position; }
  int get_money() const { return money; }

  AIGC_JSON_HELPER(position, money)  // 成员注册
 private:
  std::string position;
  int money;
};

struct Cat {
  std::string name;
  float age;
  AIGC_JSON_HELPER(name, age)  // 成员注册
};

class Student {
 public:
  std::string name;
  bool male;
  int age;
  Job job;
  std::vector<Cat> cats;
  std::vector<int> nums;
  AIGC_JSON_HELPER(name, male, age, job, cats, nums)  // 成员注册
};

int main() {
  Student person;
  std::string jsonstr = R"({"name":"ming", "male":true, "age":20,
    "job":{"position":"programer", "money":23}})";
  if (aigc::JsonHelper::JsonToObject(person, jsonstr)) {
    std::cout << "name:" << person.name << " male:" << person.male
              << " age:" << person.age
              << " job.position:" << person.job.get_position()
              << " job.money:" << person.job.get_money() << std::endl;
  }

  for (int i = 0; i < 3; ++i) {
    Cat cat;
    cat.name = "lili";
    cat.age = i + 0.1f;
    person.cats.push_back(cat);
    person.nums.push_back(i);
  }
  std::string str;
  aigc::JsonHelper::ObjectToJson(person, str);
  std::cout << str << std::endl;
  return 0;
}